package com.holdtime.jtt809dataservice.client.runnable;

import com.holdtime.jtt809dataservice.client.config.BtjjXytParentPlatfromConfig;
import com.holdtime.jtt809dataservice.client.socket.TcpClient;
import com.holdtime.jtt809dataservice.common.bean.ClientUpConnectReqDTO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * author: sunwei
 * Date: 2025/3/18 16:05
 * Description:
 */
@Slf4j
@Component
public class BtjjXytParentPlatformClientLinkHandler implements Runnable {
    @Resource
    private BtjjXytParentPlatfromConfig btjjXytParentPlatfromConfig;
    @Resource
    private TcpClient tcpClient;
    @Resource
    private ClientScheduledService clientScheduledService;

    @Override
    public void run() {
        ClientUpConnectReqDTO clientUpConnectReqDTO = new ClientUpConnectReqDTO();
        clientUpConnectReqDTO.setUserId(btjjXytParentPlatfromConfig.getUserId());
        clientUpConnectReqDTO.setPassWord(btjjXytParentPlatfromConfig.getPassword());
        clientUpConnectReqDTO.setParentPlatfromIp(btjjXytParentPlatfromConfig.getParentPlatformIp());
        clientUpConnectReqDTO.setParentPlatfromPort(btjjXytParentPlatfromConfig.getParentPlatformPort());
        clientUpConnectReqDTO.setJrm(btjjXytParentPlatfromConfig.getJrm());
        clientScheduledService.connectParentPlatform(tcpClient, clientUpConnectReqDTO);
    }
}
